package com.iflytek.tts.TtsService;

import android.os.AsyncTask;

public class TtsMsg {
	private String ttsText;
	private volatile TtsStatus mStatus = TtsStatus.PENDING;
	private TalkMode talkMode = TalkMode.TM_BUSY_WAIT;

	/**
	 * Indicates the current status of the TtsTask. Each status will be set only
	 * once during the lifetime of a task.
	 */
	public enum TtsStatus {
		/**
		 * Indicates that the task has not been executed yet.
		 */
		PENDING,
		/**
		 * Indicates that the task is running.
		 */
		RUNNING,
		/**
		 * Indicates that {@link AsyncTask#onPostExecute} has finished.
		 */
		FINISHED,
	}

	public enum TalkMode {
		TM_BUSY_WAIT, TM_BUSY_INTERRUPT, TM_BUSY_CANCEL
	}

	/**
	 * Returns the current status of this task.
	 * 
	 * @return The current status.
	 */
	public final TtsStatus getStatus() {
		return mStatus;
	}

	public TtsMsg(String ttsText) {
		this.ttsText = ttsText;
	}

	public String getTtsText() {
		return this.ttsText;
	}

	public void onPreExecute() {
	}

	public final void doTalk() {
		mStatus = TtsStatus.RUNNING;
		Tts.JniSpeak(ttsText);
		// recordLog(ttsText);
	}

	public void stop() {
		Tts.JniStop();
	}

	public void onPostExecute() {
		mStatus = TtsStatus.FINISHED;
	}

	public TalkMode getTalkMode() {
		return talkMode;
	}

	public void setTalkMode(TalkMode talkMode) {
		this.talkMode = talkMode;
	}

}
